<?php
    
    $hs_id = $_GET['hs_id'];
    $sql = "SELECT hs_path FROM home_slide WHERE hs_id=$hs_id";
    $img_old = $db->Execute($sql);
    
    $sql = "DELETE FROM home_slide WHERE hs_id=$hs_id";
    $result = $db->Execute($sql);
    
    if($result){
        $msg = 'ลบข้อมูลเรียบร้อยแล้ว';
        if(img_exists(APPPATH.'/images/home_slide',$img_old->fields['hs_path'])){
            unlink(APPPATH.'/images/home_slide/'.$img_old->fields['hs_path']);
        }
    }else{
        $msg = 'ไม่สามารถลบข้อมูลได้';
    }
?>

<?php
    include('header.php');
    include('submenu.php');
?>
<div class="grid_18" id="contents">
    <div id="query_result">
    <?php
        echo $msg , ' <img src="images/ajax-loader.gif" />';
        redirect('?m=main&s=slide',3);
    ?>
    </div>
</div><!-- end .grid_18 -->
<div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>